package com.lebang.medicalInquiry.service;


import com.lebang.medicalInquiry.mapper.LanguageConfigMapper;
import com.lebang.medicalInquiry.model.po.LanguageConfig;
import com.lebang.medicalInquiry.model.vo.PageVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @version V1.0
 * @author: zpc
 * @date:
 */
@Service
public class LanguageConfigService {
    @Resource
    private LanguageConfigMapper mapper;


    public PageVo getList(String keyWord, Integer page, Integer limit) {
        List<LanguageConfig> list = mapper.list(keyWord, (page - 1) * limit, limit);
        Integer count = mapper.count(keyWord);
        return new PageVo(list, count);
    }

    // 添加风格 需要把现有题材的都进行同步
    public void operator(LanguageConfig po) {
        if (po.getId() == null) {
            po.setCreateTime(LocalDateTime.now());
            po.setUpdateTime(LocalDateTime.now());
            po.setHasDelete(0);
            po.setState(1);
            mapper.insertSelective(po);

        } else {
            po.setUpdateTime(LocalDateTime.now());
            mapper.updateByPrimaryKey(po);
        }


    }

    // 删除
    public void remove(Integer id) {
        mapper.deleteByPrimaryKey(id);

    }

}
